import Vue from 'vue'
import VueRouter from 'vue-router'
import LayoutView from '@/layout/LayoutView'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'init',
    redirect: '/index',
  },
  {
    path: "/index",
    name: "LayoutView",
    component: LayoutView,
    redirect: '/home',
    children: [
      {
        path: "/home",
        name: "HomeView",
        hidden: true,
        meta: { title: '首页' },
        component: () => import('@/views/home/HomeView'),
      },
      {
        path: "/temp-table",
        name: "TableView",
        hidden: false,
        meta: { title: '表格管理', icon: 'table' },
        component: () => import('@/views/table/TableView')
      },
      {
        path: "/temp-pane",
        name: "PaneView",
        hidden: false,
        meta: { title: '面板管理', icon: 'appstore' },
        component: () => import('@/views/pane/PaneView')
      },
      {
        path: "/temp-form",
        name: "FormView",
        hidden: false,
        meta: { title: '表单管理', icon: 'fund' },
        component: () => import('@/views/form/FormView'),
        redirect: '/temp-form/base-form',
        children: [
          {
            path: '/temp-form/base-form',
            name: 'BaseFormView',
            hidden: false,
            meta: { title: '基础菜单' },
            component: () => import('@/views/form/BaseFormView'),
          }
        ]
      },
      {
        path: "/temp-compontents",
        name: "temp-compontents",
        hidden: false,
        meta: { title: '组件管理', icon: 'shop' },
        component: () => import('@/views/form/FormView'),
        redirect: '/temp-compontents/select-tree',
        children: [
          {
            path: '/temp-compontents/select-tree',
            name: 'SelectTreeView',
            hidden: false,
            meta: { title: '下拉树' },
            component: () => import('@/views/parts/SelectTreeView'),
          },
          {
            path: '/temp-compontents/tree',
            name: 'TreeView',
            hidden: false,
            meta: { title: '树形控件' },
            component: () => import('@/views/parts/TreeView'),
          }
        ]
      },
      {
        path: "/user-manage",
        name: "user-manage",
        hidden: false,
        meta: { title: '用户管理', icon: 'shop' },
        component: () => import('@/views/user/UserManageView'),
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
